﻿using AutoMapper;
using Pay.Core;
using Pay.Data;
using Pay.DTO;
using Pay.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service.AutoMapper {

    public class QuotaRecordMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public QuotaRecordMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<QuotaRecord, quota_record_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.merchant_name, src => src.MapFrom(c => c.MerchantName))
                .ForMember(dest => dest.account_mobile, src => src.MapFrom(c => c.Merchant.Mobile))
                .ForMember(dest => dest.apply_num, src => src.MapFrom(c => c.ApplyNum))
                .ForMember(dest => dest.moblie, src => src.MapFrom(c => c.Moblie))
                .ForMember(dest => dest.apply_time, src => src.MapFrom(c => c.ApplyTime.ToDateTime()))
                 .ForMember(dest => dest.audit_time, src => src.MapFrom(c => c.AuditTime.ToDateTime()))
                 .ForMember(dest => dest.audit_num, src => src.MapFrom(c => c.AuditNum))
                  .ForMember(dest => dest.equota_record_audit, src => src.MapFrom(c => c.EQuotaRecordAudit))
                        .ForMember(dest => dest.equota_record_audit_desc, src => src.MapFrom(c => c.EQuotaRecordAudit.ToDescription()))
                .ForMember(dest => dest.remark, src => src.MapFrom(c => c.Remark));



            _cfg.CreateMap<quota_record_dto, QuotaRecord>()
                  .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                  .ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchant_id))
                  .ForMember(dest => dest.MerchantName, src => src.MapFrom(c => c.merchant_name))
                  .ForMember(dest => dest.ApplyNum, src => src.MapFrom(c => c.apply_num))
                  .ForMember(dest => dest.Moblie, src => src.MapFrom(c => c.moblie))
                  .ForMember(dest => dest.ApplyTime, src => src.MapFrom(c => c.apply_time.ToUnix()))
                   .ForMember(dest => dest.AuditTime, src => src.MapFrom(c => c.audit_time.ToUnix()))
                   .ForMember(dest => dest.AuditNum, src => src.MapFrom(c => c.audit_num))
                    .ForMember(dest => dest.EQuotaRecordAudit, src => src.MapFrom(c => c.equota_record_audit))
                  .ForMember(dest => dest.Remark, src => src.MapFrom(c => c.remark));


        }
    }
}
